home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 12219 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.2 KB

  1. Path: mail2news.demon.co.uk!genesis.demon.co.uk
  2. From: Lawrence Kirby <fred@genesis.demon.co.uk>
  3. Newsgroups: comp.dsp,comp.lang.c
  4. Subject: Re: C code .vs. Assembly code for Microcontrollers/DSPs ?
  5. Date: Fri, 29 Mar 96 19:29:42 GMT
  6. Organization: none
  7. Message-ID: <828127782snz@genesis.demon.co.uk>
  8. References: <620174950wnr@dstrip.demon.co.uk> <4j9lfh$o2l@narses.hrz.tu-chemnitz.de> <436922997wnr@dstrip.demon.co.uk>
  9. Reply-To: fred@genesis.demon.co.uk
  10. X-NNTP-Posting-Host: genesis.demon.co.uk
  11. X-Newsreader: Demon Internet Simple News v1.27
  12. X-Mail2News-Path: genesis.demon.co.uk
  13.  
  14. In article <436922997wnr@dstrip.demon.co.uk>
  15.            Steve@dstrip.demon.co.uk "Steve Rencontre" writes:
  16.  
  17. >In article: <4j9lfh$o2l@narses.hrz.tu-chemnitz.de>  
  18. >hfst@hrz.tu-chemnitz.de (Hans Steffani) writes:
  19. >> Steve Rencontre <Steve@dstrip.demon.co.uk> writes:
  20. >> 
  21. >> >Oh yes it can!
  22. >> 
  23. >> >     ...     
  24. >> >     int var1, var2;
  25. >> >     int *var1p = &var1;
  26. >> >     var1p[-1] = 0;
  27. >> >     ...
  28. >> 
  29. >> Post this to comp.lang.c[.moderated] and you will be told that this
  30. >> leads to undefined behavior and something like that. 
  31. >
  32. >Well my newsreader doesn't know how to post to moderated groups, and I'm 
  33. >too lazy to do it by hand :-), but anyway...
  34.  
  35. Have you tried posting as normal?
  36.  
  37. >It may be undefined by the *language*, but then so is the size of an 
  38. >int!
  39.  
  40. The size of an int is implementation defined so it is guaranteed to have a
  41. value. Moreover the language guarantees that you can store any number in
  42. the range -32767 to 32767 inclusive in an int on any implementation. That
  43. is a world apart from the plain undefined behaviour that the code above
  44. results in.
  45.  
  46. >However, this very behaviour is relied on by stdargs/varargs in 
  47. >order to make variable parameter lists possible. Yes, it's 
  48. >implementation-dependent -- but that doesn't mean it results in 
  49. >unpredictable or unreliable behaviour within that implementation.
  50.  
  51. True, but it does mean that it is non-portable. Not knowing the intent and
  52. use of the code from what has appeared in comp.lang.c I cannot say
  53. whether that is significant or not. Usually it is.
  54.  
  55. -- 
  56. -----------------------------------------
  57. Lawrence Kirby | fred@genesis.demon.co.uk
  58. Wilts, England | 70734.126@compuserve.com
  59. -----------------------------------------
  60.